import { PropsWithChildren, useRef } from "react";
import { Modal, message, notification, App } from 'antd';


export default function AppWrapper(props: PropsWithChildren){
  const rewrited = useRef(false);
  const {message: appMessage, modal, notification: appNotification} = App.useApp();

  if(!rewrited.current){
    Modal.confirm = modal.confirm;
    Modal.info = modal.info;
    Modal.success = modal.success;
    Modal.warning = modal.warning;
    message.success = appMessage.success;
    message.warning = appMessage.warning;
    message.error = appMessage.error;
    message.info = appMessage.info;
    notification.success = appNotification.success;
    notification.warning = appNotification.warning;
    notification.error = appNotification.error;
    notification.info = appNotification.info;
    rewrited.current = true;
  }

  return props.children;
}
